package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import java.util.List;
import dataAccessDomain.Location;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;

public class SearchWindows extends JFrame implements ActionListener {
	private JPanel mainPanel;
	private JList listResearch;
	private DefaultListModel jListModel;
	
//	public SearchWindows(List<Location> listLocation) {
//		
//		this.setTitle("Recherche");
//		this.setSize(100, 150);
//		this.setLocationRelativeTo(null);
//		this.setResizable(true);
//		this.setContentPane(buildContentPane(listLocation));
//		this.setVisible(true);
//		
//		
//	}
	
	
	public void build(List<Location> listLocation){
		//System.out.println("build "+ name);
		this.setTitle("Recherche");
		this.setSize(200, 200);
		this.setLocationRelativeTo(null);
		this.setResizable(true);
		this.setContentPane(buildContentPane(listLocation));
		this.setVisible(true);
	}
	
	public JPanel buildContentPane(List<Location> listLocation){
		//System.out.println("buildContentPane");
		mainPanel = new JPanel();
		//jListModel = new DefaultListModel();
		listResearch = new JList();
		JScrollPane panel = new JScrollPane(listResearch);
//		int i;
//		for (i=0 ; i < listLocation.size() ; i++) {
//			listResearch.setListData(listLocation.toArray());
//			
//		}
		listResearch.setListData(listLocation.toArray());
		mainPanel.add(panel);
		//getContentPane().add(listResearch);
		
		return mainPanel;		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}
}
